package com.huicoo.forestmanager.util.glide;

import android.content.Context;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.huicoo.forestmanager.R;

//全局唯一的用于加载图片的Loader
public class ExploreImageLoader {
    private ExploreImageLoader() {

    }

    static class WrapperInstance {
        static ExploreImageLoader INSTANCE = new ExploreImageLoader();
    }

    public static ExploreImageLoader getInstance() {
        return WrapperInstance.INSTANCE;
    }

    public void loadImage(Context context, String url, ImageView imageView) {
        RequestOptions options = new RequestOptions()
                .fallback(R.drawable.pic_default) //url为空的时候,显示的图片
                .error(R.drawable.pic_default)
                .dontAnimate();//图片加载失败后，显示的图片

        Glide.with(context).load(url).apply(options).into(imageView);
    }

}
